home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of NeuroSolutions Function component for Sine setting
-
- #include "NSDLL.h"
-
- /***************************/
- /* Activation of component */
- __declspec(dllexport) NSFloat performFunction(
- DLLData *instance, // Pointer to instance data (may be NULL)
- NSFloat x // Current argument in radians
- )
- {
- int cycles = getIntParameter(instance, 3, 1);
- NSFloat decay = getFloatParameter(instance, 2, 1);
- NSFloat *amplitudeDecay = getUserData(instance);
- NSFloat function = (NSFloat)(*amplitudeDecay*sin(cycles*x));
- *amplitudeDecay *= decay;
- return function;
- }
-
- /**********************************************************************/
- /* Called before any performFunction calls, allowing any initialization. */
- __declspec(dllexport) void getReadyToFire(
- DLLData *instance // Pointer to instance data (may be NULL)
- )
- {
- NSFloat *amplitudeDecay = getUserData(instance);
- *amplitudeDecay = 1.0f;
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
- __declspec(dllexport) DLLData *allocFunction(
- DLLData *oldInstance // Pointer to the last instance if reallocating
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- setParameterName(instance, 3, 1, "Cycles", FALSE);
- setIntParameter(instance, 3, 1, 5, FALSE);
- setParameterName(instance, 2, 1, "Decay", FALSE);
- setFloatParameter(instance, 2, 1, 0.9f, FALSE);
- setUserData(instance, malloc(sizeof(NSFloat)));
- return instance;
- }
-
- __declspec(dllexport) void freeFunction(DLLData *instance)
- {
- if (getUserData(instance))
- free((NSFloat*)getUserData(instance));
- freeDLLInstance(instance);
- }
-